package vip.liux.contracts.models.notification;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import vip.liux.contracts.shared.enums.SendStatus;
import vip.liux.contracts.shared.enums.messing.ChannelType;
import vip.liux.domain.entities.auditing.CreationAuditedEntity;

import java.time.LocalDateTime;

/**
 * 通知消息发送任务实体类
 * 表示发送给用户的具体通知消息
 */
@Getter
@Setter
@Entity
@Table(name = "message_dispatch")
public class MessageDispatch extends CreationAuditedEntity<Long> {

    /**
     * 消息模板 ID
     */
    @Column(name = "task_id", nullable = false)
    private Long taskId;

    /**
     * 消息接收者
     */
    @Column(name = "receiver", nullable = false)
    private String receiver;

    /**
     * 通知渠道类型 0 - 站内消息 1 - 短信 2 - 邮件 3 - Webhooks
     *
     * @see ChannelType
     */
    @Column(name = "channel_type", nullable = false)
    private ChannelType channelType;

    /**
     * 消息状态 0 - 未投递 1 - 成功 2 - 失败 3 - 回执
     */
    @Column(name = "status", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private SendStatus status;

    /**
     * 失败原因、回执内容等
     */
    @Column(name = "result", nullable = false, columnDefinition = "TEXT")
    private String result;

    /**
     * 应答时间
     */
    @Column(name = "ack_time")
    private LocalDateTime ackTime;
}
